{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-03T04:53:22.867808Z",
     "start_time": "2018-09-03T04:53:22.863797Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "model_list = ['OLS3','PLS','PCR','ENet','GLM','RF','GBRT','NN1','NN2','NN3','NN4','NN5']\n",
    "removelist = ['PLS','GLM','NN2','NN3','NN4','NN5']\n",
    "for x in removelist:\n",
    "    model_list.remove(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-03T08:32:49.275243Z",
     "start_time": "2018-09-03T08:32:49.271730Z"
    }
   },
   "outputs": [],
   "source": [
    "length = 4\n",
    "higth = 5\n",
    "x = np.zeros(shape=(length,higth))\n",
    "real = np.array([0.9,1.9,2.9,3.9,4.9])\n",
    "x[0]= np.array([1,2,3,4,5])\n",
    "x[1] = np.array([1.1,2.2,3.3,4.4,5.5])\n",
    "x[2] = np.array([1.3,2.3,3.6,4.4,5.5])\n",
    "x[3] = np.array([1.3,2.9,3.3,4.8,5.9])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-03T08:32:49.667695Z",
     "start_time": "2018-09-03T08:32:49.663684Z"
    }
   },
   "outputs": [],
   "source": [
    "def D_M_test_fun(x,real):\n",
    "    length = len(x)\n",
    "    matrix = np.zeros(shape=(length,length))\n",
    "    for i in range(length):\n",
    "        x[i] = np.square(x[i] - real)\n",
    "    for i in range(length):\n",
    "        count_num = length - i - 1\n",
    "        for j in range(count_num):\n",
    "            matrix[i][i+j+1] = (np.sum(x[i] - x[i+j+1]))/higth\n",
    "    return matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-03T08:32:50.019504Z",
     "start_time": "2018-09-03T08:32:50.015495Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.   , -0.17 , -0.274, -0.616],\n",
       "       [ 0.   ,  0.   , -0.104, -0.446],\n",
       "       [ 0.   ,  0.   ,  0.   , -0.342],\n",
       "       [ 0.   ,  0.   ,  0.   ,  0.   ]])"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " D_M_test_fun(x,real)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-09-03T08:25:07.004311Z",
     "start_time": "2018-09-03T08:25:07.000329Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.   , -0.17 , -0.274, -0.616],\n",
       "       [ 0.   ,  0.   , -0.104, -0.446],\n",
       "       [ 0.   ,  0.   ,  0.   , -0.342],\n",
       "       [ 0.   ,  0.   ,  0.   ,  0.   ]])"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "position": {
    "height": "253.8px",
    "left": "921px",
    "right": "20px",
    "top": "131px",
    "width": "535.4px"
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
